package com.aj.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;

import com.aj.http.AsynchronizationHttpRequest.IHttpCallBack;
import com.aj.http.request.UpdateRequest;
import com.aj.sharepreferences.LoveHomeSharedPreferences;
import com.aj.utils.Contants;
import com.aj.utils.MobileUtil;

public class WelcomeActivity extends Activity {
	private static final String TAG = WelcomeActivity.class.getName();

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_welcome);
		UpdateRequest updateRequest = new UpdateRequest();
		updateRequest.excute(this, MobileUtil.getVersionName(this),
				new IHttpCallBack() {
					@Override
					public void success(String result) {
						Log.e(TAG, "result:" + result);
					}

					@Override
					public void fail(String result) {
						Log.e(TAG, "result:" + result);
					}
				});
		handler.sendEmptyMessageDelayed(0, 3000);
	}

	private Handler handler = new Handler(new Handler.Callback() {
		@Override
		public boolean handleMessage(Message msg) {
			Intent intent = null;
			if (!LoveHomeSharedPreferences.getWelcomeGuideFlag()) {
				intent = new Intent(Contants.GUIDEACTIVITY_ACTION);
			} else {
				intent = new Intent(Contants.LOGINACTIVITY_ACTION);
			}
			startActivity(intent);
			finish();
			return true;
		}
	});
}
